import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;

public class Room {

    private List<Card> cards = new ArrayList<>();

   public Room(){
        String[] numbers = new String[]{"3","4","5","6","7","8","9","10","J","Q","K","A","2"};
        String[] color = new String[]{"♥","♠","♦","♣"};
        int size = 0;

       for (String n:numbers) {
            size++;
           for (String c:color) {

               Card card = new Card(n,c,size);
               cards.add(card);
           }
       }
       Card c1 = new Card("","♞",++size);
       Card c2 = new Card("","♛",++size);
       Collections.addAll(cards,c1,c2);
       System.out.println(cards);

    }
    public void start(){

       Collections.shuffle(cards);
        System.out.println(cards);

       List<Card> wu = new ArrayList<>();
       List<Card> yu = new ArrayList<>();
       List<Card> tong = new ArrayList<>();
        System.out.println("------------------------------------");

        for (int i = 0; i < cards.size()-3; i++) {
            if (i % 3 == 0){
                wu.add(cards.get(i));
            } else if (i % 3 == 1) {
                yu.add(cards.get(i));
            } else if (i % 3 == 2) {
                tong.add(cards.get(i));
            }
        }

        List<Card> lastCard = cards.subList(cards.size()-3,cards.size());
        System.out.println(lastCard);
        wu.addAll(lastCard);

        //排序
        mySort(wu);
        mySort(yu);
        mySort(tong);

        System.out.println(wu);
        System.out.println(yu);
        System.out.println(tong);

    }
    private void mySort(List<Card> cardList){
       Collections.sort(cardList, (o1, o2)-> o1.getSize() - o2.getSize());

    }

}
